package top.chenfu.aop;

import org.springframework.stereotype.Component;
import top.chenfu.aop.anno.Demo1Aop;
import top.chenfu.aop.anno.Demo2Aop;

import java.util.HashMap;

/**
 * @Auther chenfu
 * @2019/11/6 11:11
 * @Desc    被代理的类对象
 */
@Component
public class Business {

    @Demo1Aop
    @Demo2Aop
    public Object run(Integer id) {
        System.out.println(this.getClass() + "=====" + id);
        HashMap<String, Object> map = new HashMap<>();
        map.put("userId", id);
//        在run2上注解不会生效，因为是代理类内部的自调用，不存在AOP
        run2(id);
        return map;
    }

    @Demo1Aop
    @Demo2Aop
    public Object run2(Integer id) {
        System.out.println(this.getClass() + "===run2==" + id);
        HashMap<String, Object> map = new HashMap<>();
        map.put("userId", id);
        return map;
    }

}
